package cn.wolfcode.cms.service.impl;

import cn.wolfcode.cms.domain.Membernum;
import cn.wolfcode.cms.mapper.MembernumMapper;
import cn.wolfcode.cms.query.QueryObject;
import cn.wolfcode.cms.service.IMembernumService;
import cn.wolfcode.cms.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MembernumServiceImpl implements IMembernumService {

    @Autowired
    private MembernumMapper membernumMapper;

    public void save(Membernum entity) {
        membernumMapper.insert(entity);

    }

    public void update(Membernum entity) {
        membernumMapper.updateByPrimaryKey(entity);
    }

    public void delete(Long id) {
        membernumMapper.deleteByPrimaryKey(id);
    }

    public Membernum get(Long id) {
        return membernumMapper.selectByPrimaryKey(id);
    }

    public List<Membernum> list() {
        return membernumMapper.selectAll();
    }

    public Object query(QueryObject qo) {
        //查总数
        int total = membernumMapper.queryForCount(qo);
        if (total == 0) {
            return new PageResult();
        }
        //查数据
        List<Membernum> rows = membernumMapper.queryForList(qo);
        return new PageResult(total, rows);
    }

}
